<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS 浮动依次贴边</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width: 600px;
            height: 400px;
            border: 5px solid red;
            margin: 100px auto;
        }
        div p{
            width: 100px;
            height: 100px;
            float: left;
        }
        div p.par1{
            height: 250px;
            background-color: green;
        }
        div p.par2{
            width: 330px;
            background-color: blue;
        }
        div p.par3{
            height: 200px;
            background-color: yellow;
        }
        div p.par4{
            width: 650px;
            background-color: cyan;
        }
    </style>
</head>
<body>
    <div>
        <p class="par1">1</p>
        <p class="par2">2</p>
        <p class="par3">3</p>
        <p class="par4">4</p>
    </div>
</body>
</html>